//
//  TTMarketViewCell.m
//  TaoTuo
//
//  Created by 周晨晔 on 2019/9/19.
//  Copyright © 2019 admin. All rights reserved.
//

#import "TTMarketViewCell.h"

@interface TTMarketViewCell ()

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *goupLabel;
@property (weak, nonatomic) IBOutlet UILabel *hightLabel;
@property (weak, nonatomic) IBOutlet UILabel *downLabel;
@property (weak, nonatomic) IBOutlet UISwitch *mySwitch;


@end

@implementation TTMarketViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.mySwitch.transform = CGAffineTransformMakeScale(0.75, 0.75);
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = [UIColor whiteColor];
}

// 点击了
- (IBAction)clickSwitch:(UISwitch *)sender
{
    self.model.isOpen = sender.on;
    TTLoginSingle *single = [TTLoginSingle sharedSingle];
    if (single.isLogin) {
        [USER_DEFAULT setBool:YES forKey:@"user_behavior"]; // 用户自己选择的
        [single.marketDic setObject:@(sender.on) forKey:self.model.Code];
    } else {
        [single.unLoginMarketDic setObject:@(sender.on) forKey:self.model.Code];
    }
}

- (void)setModel:(TTMarketModel *)model
{
    _model = model;
    self.nameLabel.text = model.Text;
    self.dateLabel.text = self.model.DateTimeText;
    self.priceLabel.text = self.model.Price;
    self.goupLabel.text = self.model.BackPrice;
    self.hightLabel.text = self.model.PriceMax;
    self.downLabel.text = self.model.PriceMin;
    
    self.mySwitch.on = self.model.isOpen;
    
    if ([self.model.UpsAndDownsPrice hasPrefix:@"+"]) {
        self.priceLabel.textColor = UIColorHex(E74C3C);
//        self.goupLabel.textColor = [UIColor whiteColor];
//        self.goupLabel.backgroundColor = UIColorHex(E74C3C);
    } else if ([self.model.UpsAndDownsPrice hasPrefix:@"-"]) {
        self.priceLabel.textColor = UIColorHex(2ECC71);
//        self.goupLabel.textColor = [UIColor whiteColor];
//        self.goupLabel.backgroundColor = UIColorHex(2ECC71);
    } else {
        self.priceLabel.textColor = UIColorHex(333333);
//        self.goupLabel.backgroundColor = [UIColor whiteColor];
    }
    
}




@end
